<template>
  <div>
    <SelfTitle :userName="username"></SelfTitle>
    <div class="manageContent">
      <!-- 头部搜索框 -->
      <div class="manageSearch">
        <el-input placeholder="请输入内容" class="mobelSeachInput" v-model="demandName"></el-input>
        <div class="box" style="background:white">
          <el-select
            v-model="demandStatus"
            placeholder="请选择状态"
            @change="changeStatus"
          >
            <el-option label="未处理" value="未处理"> </el-option>
            <el-option label="处理中" value="处理中"> </el-option>
            <el-option label="处理完成" value="处理完成"> </el-option>
            <el-option label="需求关闭" value="需求关闭"> </el-option>
          </el-select>
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="timeDemand"
            @change="timeChange"
          >
          </el-date-picker>
          <el-input
                  v-model="demandCategory"
                  placeholder="请输入需求分类"
          ></el-input>
          <el-input
                  v-model="demandDescribes"
                  placeholder="请输入描述"
          ></el-input>
          <el-input
                  v-model="demandEnter_name"
                  placeholder="请输入企业用户名称"
          ></el-input>
          <el-input
                  v-model="demandName"
                  placeholder="请输入需求名称"
          ></el-input>
          <el-input
                  v-model="demandPro_name"
                  placeholder="请输入项目名称"
          ></el-input>
        </div>

        <el-button class="reqSearchBtn" @click="searchDemand">搜索</el-button>
        <el-button class="reqCancleBtn" @click="cancelSearchDemand"
          >取消</el-button
        >
        <el-button  @click="enterProject"
          >我的项目</el-button
        >
        <el-button @click="seeUser">查看用户</el-button>
      </div>

      <div class="tableBox">
        <el-table
          border
          :data="allShowInfo"
          style="width: 100%"
          :header-cell-style="{
            background: '#E9E9E9',
            color: '#606266',
            fontWeight: 600,
          }"
        >
          <el-table-column label="序号" width="50" type="index" align="center">
          </el-table-column>
          <el-table-column label="需求名称" width="100" align="center">
            <template slot-scope="scope">
              <div
                @click="enterReqDetail(scope.row.demandId, scope.row.projectId)"
              >
                {{ scope.row.demandName }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="demandDescribe"
            label="需求描述"
            align="center"
          >
            <template slot-scope="scope">
              <div class="reqDesc">{{ scope.row.demandDescribe }}</div>
            </template>
          </el-table-column>

          <el-table-column label="需求文档" width="100" align="center">
            <template slot-scope="scope">
              <div>
                <a v-if="scope.row.docReqFilesUrl" :href="scope.row.docReqFilesUrl">点击下载</a>
                <span v-else>暂无文件</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column
            prop="enterpriseId"
            label="所属企业"
            width="120"
            align="center"
          >
            <template slot-scope="scope">
              <div>
                  <div>
                    {{ scope.row.enterpriseName?scope.row.enterpriseName:"暂无企业信息"}}
                  </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column
            prop="relation"
            label="需求分类"
            align="center"
            width="150"
          >
          </el-table-column>

          <el-table-column
            prop="projectName"
            label="项目名称"
            align="center"
            width="120"
          >
            <template slot-scope="scope">
              <div @click="createSubject(scope.row)">
                {{
                  scope.row.isCreated ? scope.row.projectName : "[ 点击创建 ]"
                }}
              </div>
            </template>
          </el-table-column>

          <el-table-column
            prop="gmtCreated"
            label="需求创建时间"
            align="center"
            width="160"
          >
          </el-table-column>

          <el-table-column
            prop="contact"
            label="联系方式"
            width="140"
            align="center"
          >
          </el-table-column>

          <el-table-column
            prop="docFilesUrl"
            label="已发送文件"
            width="100"
            align="center"
          >
            <template slot-scope="scope">
              <div v-if="scope.row.docFilesUrl">
                <a :href="scope.row.docFilesUrl" class="textUpload">点击下载</a>
              </div>
              <div v-else>
                暂未发送
              </div>
            </template>
          </el-table-column>

          <el-table-column
            prop="status"
            label="状态"
            width="130"
            align="center"
          >
            <template slot-scope="scope">
              <div>
                <div v-if="scope.row.demandStatus === 0">
                  <el-select
                          v-model="scope.row.modifyStatus"
                          placeholder="未处理"
                          @change="
                      mdfStatus(scope.row.demandId, scope.row.modifyStatus)
                    "
                          clearable
                  >
                    <el-option label="未处理" value="未处理"> </el-option>
                    <el-option label="处理中" value="处理中"> </el-option>
                    <el-option label="处理完成" value="处理完成"> </el-option>
                    <el-option label="需求关闭" value="需求关闭"> </el-option>
                  </el-select>
                </div>
                <div v-if="scope.row.demandStatus === 1">
                  <el-select
                          v-model="scope.row.modifyStatus"
                          placeholder="处理中"
                          @change="
                      mdfStatus(scope.row.demandId, scope.row.modifyStatus)
                    "
                          clearable
                  >
                    <el-option label="未处理" value="未处理"> </el-option>
                    <el-option label="处理中" value="处理中"> </el-option>
                    <el-option label="处理完成" value="处理完成"> </el-option>
                    <el-option label="需求关闭" value="需求关闭"> </el-option>
                  </el-select>
                </div>
                <div v-if="scope.row.demandStatus === 2">
                  <el-select
                          v-model="scope.row.modifyStatus"
                          placeholder="处理完成"
                          @change="
                      mdfStatus(scope.row.demandId, scope.row.modifyStatus)
                    "
                          clearable
                  >
                    <el-option label="未处理" value="未处理"> </el-option>
                    <el-option label="处理中" value="处理中"> </el-option>
                    <el-option label="处理完成" value="处理完成"> </el-option>
                    <el-option label="需求关闭" value="需求关闭"> </el-option>
                  </el-select>
                </div>
                <div v-if="scope.row.demandStatus === 3">
                  <el-select
                          v-model="scope.row.modifyStatus"
                          placeholder="需求关闭"
                          @change="
                      mdfStatus(scope.row.demandId, scope.row.modifyStatus)
                    "
                          clearable
                  >
                    <el-option label="未处理" value="未处理"> </el-option>
                    <el-option label="处理中" value="处理中"> </el-option>
                    <el-option label="处理完成" value="处理完成"> </el-option>
                    <el-option label="需求关闭" value="需求关闭"> </el-option>
                  </el-select>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column
            prop="assess"
            label="项目评分"
            width="120"
            align="center"
          >
            <template slot-scope="scope">
              <div class="reqAllAssess" @click="subjectAssess(scope.row)">
                <i class="el-icon-remove-outline"></i>
              </div>
            </template>
          </el-table-column>
        </el-table>

        <div class="el-pagination-size">
          <el-pagination
            :page-sizes="[5, 10, 15]"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :total="totalCount"
          >
          </el-pagination>
        </div>
      </div>

      <!-- 创建项目 -->
      <el-dialog
        :visible.sync="createSubjectVisible"
        width="35%"
        class="createSubjectStyle"
      >
        <h2>创建项目</h2>
        <!-- 表单数据 -->
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="需求名称">
            <el-input v-model="demandName" disabled></el-input>
          </el-form-item>
          <el-form-item label="项目名称" prop="projectName">
            <el-input v-model="ruleForm.projectName"></el-input>
          </el-form-item>
          <el-form-item label="联系方式" prop="contact">
            <el-input v-model="ruleForm.contact"></el-input>
          </el-form-item>
          <el-form-item label="项目分类" prop="categoryId">
            <el-select
              v-model="ruleForm.categoryId"
              placeholder="请选择项目分类"
            >
              <el-option
                v-for="item in demandClassify"
                :label="item.value"
                :value="item.id"
                :key="item.id"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="人员分配" prop="">
            <div class="personCate">
              <span>
                <i
                        class="el-icon-edit"
                        v-if="addPlaceState"
                        @click="addPlace"
                ></i>
                <el-input v-else v-model="placeData"></el-input>
              </span>
              <span>
                <el-cascader
                        v-model="value"
                        :options="options"
                        @change="handleChange"
                ></el-cascader
                ></span>
            </div>
          </el-form-item>
        </el-form>

        <div
          v-for="(item, index) in currentPersonChoose"
          :key="index"
          class="selectedPerson"
        >
          <span>{{ item[0] }}</span>
          <span>{{ item[1] }}</span>
          <span>{{ item[2] }}</span>
          <span @click="deleteOnePersonByInd(index)"> X </span>
        </div>

        <div class="btn" style="margin-top: 30px;">
          <el-button type="primary" @click="createProjectBtn">创建</el-button>
          <el-button @click="createSubjectVisible = false">取消</el-button>
        </div>
      </el-dialog>

      <!-- 在手机端展示 -->
      <div class="tableBoxMobel">
        <ul>
          <li
            v-for="(item, index) in allShowInfo"
            :key="index"
            @click="
              enterReqDetailMobel(item.isCreated, item.demandId, item.projectId)
            "
          >
            <span>{{ item.demandName }}</span>
            <span v-if="!item.isCreated">创建项目</span>
            <span v-else>{{ item.projectName}}</span>
          </li>
        </ul>
        <div class="paginationVan">
          <van-pagination
                  @change="mobelChangePage"
                  v-model="currentPage"
                  :total-items="totalCount"
                  :items-per-page="pageSize"
                  force-ellipses
          />
        </div>
      </div>

      <!-- 项目评分 -->
      <el-dialog
        :visible.sync="subjectAssessVisible"
        width="35%"
        class="subjectAssessStyle"
      >
        <h2>项目评分</h2>

        <ul>
          <li>
            <span class="subjectOneTitle">
              <span>{{ projectObj.projectName }}</span>
              <span class="subjectRoleStyle"
                >（{{
                  projectObj.projectStatus === 0 ? "未完成" : "已完成"
                }}）</span
              ></span
            >
            <el-rate v-model="projectObj.projectScore"> </el-rate>
          </li>
        </ul>

        <ul>
          <li
            v-for="(item, index) in currentScore.users"
            :key="'subject' + index"
          >
            <span class="subjectOneTitle">
              <span>{{ item.name }}</span>
              <span class="subjectRoleStyle"
                >（{{ item.position }}）</span
              ></span
            >
            <el-rate v-model="item.score"> </el-rate>
          </li>
        </ul>

        <div class="moreInfo">
          <span>备注</span>
          <el-input
            type="textarea"
            :autosize="{ minRows: 4, maxRows: 4 }"
            placeholder="请输入内容"
            v-model="projectObj.mark"
          >
          </el-input>
        </div>

        <div class="btnBox">
          <el-button size="mini" type="primary" @click="saveScoreProject"
            >保 存</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="subjectAssessVisible = false"
            >取 消</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import SelfTitle from "@/components/SelfTitle.vue";
import dayjs from "dayjs";
import {
  ReqAllDemand,
  ReqAllProject,
  ReqAllDemandClassify,
  ReqCooperativeUser,
  ReqEnterPriseUser,
  ReqCooperPersonUser,
  ReqAddProject,
  ReqListScorePro,
  ReqPersonByProjectId,
  ReqProjectScore,
  ReqUpdateScorePro,
  ReqDemandByStatus,
  ReqManchangeStatus,
  ReqPersonalUser,
  ReqadminList,
  ReqPersonal
} from "../../../request";
export default {
  data() {
    return {
      demandClassify: [],
      cooperativeUser: [],
      allDemend: [],
      allShowInfo: [],
      enterPriseUser: [],
      subjectAssessVisible: false,
      createSubjectVisible: false,
      projectCateId: "", //项目分类id
      ruleForm: {},
      subjectData: [
        { title: "赋能中心", status: "已完成", score: 1 },
        { title: "吴某某", status: "UI设计", score: 2 },
        { title: "张某某", status: "项目经理", score: 3 },
        { title: "赵某某", status: "前端负责人", score: 2 },
        { title: "王某某", status: "后端负责人", score: 3 },
        { title: "王某某", status: "后端负责人", score: 3 },
      ],
      // 表单验证
      rules: {
        projectName: [
          { required: true, message: "请输入项目名称", trigger: "blur" },
        ],
        contact: [
          { required: true, message: "请输入联系方式", trigger: "blur" },
        ],
        categoryId: [
          { required: true, message: "请选择项目分类", trigger: "change" },
        ],
      },
      // 表单数据
      ruleForm: {
        demandId: "",
        projectName: "",
        contact: "",
        categoryId: "",
        userRelations: [],
        createdAdminId: 1,
        docFilesUrl: "",
      },
      currentPersonChoose: [],
      newArr: [],
      // 需求名称
      demandName: "",
      // 级联选择框选项
      value: [],
      currentScore: {},
      projectObj: {},
      options: [],
      // 判断是否已经评分（用于更新操作）
      isAccess: false,
      // 保存当前评分id
      currentAccessId: "",
      value1: "",
      currentPage: 0,
      pageSize: 10,
      totalCount: 0,
      demandStatus: "", //查询需求状态
      timeDemand: "", //查询需求时间
      userType:'',
      username:'',
      demandCategory: "",
      demandDescribes: "",
      demandEnter_name: "",
      demandName: "",
      demandPro_name: "",
      userType: "",
      username: "",
      modifyStatus: [],
      roles: [],
      myCpnusers: [], //赋能中心个人顾问
      adminUsers: [], //管理员用户
      otherCpnusers: [], //其他企业的个人顾问
      addPlaceState: true,
      placeData: "",
    };
  },
  components: {
    SelfTitle,
  },
  methods: {
    async mdfStatus(id, status) {
      let formData = new FormData();
      formData.append("id", id);
      formData.append("status", status);
      console.log(formData)
      let result = await ReqManchangeStatus(formData);
      console.log('87',result);
      if (result.msg === "success") {
        this.$message({
          showClose: true,
          message: "修改成功",
          type: "success"
        });
      } else {
        this.$message({
          showClose: true,
          message: "修改失败",
          type: "error"
        });
      }
    },
    addPlace() {
      this.addPlaceState = false;
    },
    // 查看用户
    seeUser() {
      this.$router.history.push("/self/manage/ManUser");
    },
    // 项目评分
    async subjectAssess(data) {
      const { isCreated, projectId, status, remarks, projectName } = data;
      if (!isCreated) {
        this.$message({
          type: "danger",
          message: "项目未创建, 请先创建项目!",
        });
        return;
      }
      const scoreDetail = await ReqListScorePro({
        createdId: 1,
        scoredId: projectId,
      });
      console.log(scoreDetail);
      const { scoreEntity } = scoreDetail;
      if (scoreEntity) {
        const { scoreDetails, id } = scoreEntity;
        this.currentScore = JSON.parse(scoreDetails);
        this.projectObj = this.currentScore.project;
        this.isAccess = true;
        this.currentAccessId = id;
      } else {
        this.isAccess = false;
        const projectPerson = await ReqPersonByProjectId({ projectId });
        const { scoreVo } = projectPerson;
        this.projectObj = {
          projectId,
          projectName: projectName,
          projectScore: 0,
          projectStatus: status,
          mark: remarks,
        };
        this.currentScore.project = this.projectObj;
        this.currentScore.users = scoreVo;
      }
      this.subjectAssessVisible = true;
    },
    enterReqDetail(demandId, projectId) {
      this.$router.history.push(
        `/self/manage/manReqDetail?demandId=${demandId}&projectId=${projectId}`
      );
    },
    // 进入需求详情页手机端
    enterReqDetailMobel(isCreated, demandId, projectId) {
      if (isCreated) {
        this.$router.history.push(
          `/self/manage/reqDetailMobel?demandId=${demandId}&projectId=${projectId}`
        );
      } else {
        this.$router.history.push(
          `/self/manage/createProjectMobel?demandId=${demandId}`
        );
      }
    },
// 手机端改变页码
    async mobelChangePage() {
      await this.getAllDemend();
    },
    createSubject(data) {
      if (!data.isCreated) {
        this.createSubjectVisible = true;
        this.ruleForm.demandId = data.demandId;
        this.demandName = data.demandName;
      }
    },
    // 获取全部的项目
    async getAllProject() {
      let tableData = await ReqAllProject();
      let { projectVo } = tableData;
      this.tableData = projectVo;
    },
    // 获取全部的需求分类
    async getAllReqClassify() {
      let demandClassify = await ReqAllDemandClassify();
      let { category } = demandClassify;
      this.demandClassify = category;
    },
    async getAllDemend() {
      const allDemandInfo = await ReqAllDemand({
        limit: this.pageSize,
        page: this.currentPage,
      });
      console.log("allDemandInfo", allDemandInfo);
      const {
        page: { list, totalCount },
      } = allDemandInfo;
      // console.log("list", list);
      this.totalCount = totalCount;
      this.allShowInfo = [];
      list.forEach((item) => {
        let isCreated;
        if (item.project) {
          isCreated = true;
        } else {
          isCreated = false;
        }
        // console.log(item);
        this.allShowInfo.push({        
          demandStatus:item.demand?.status,
          demandId: item.demand?.id,
          demandName: item.demand?.demandName,
          demandDescribe: item.demand?.demandDescribe,
          docReqFilesUrl: item.demand?.docFilesUrl,
          enterpriseId: item.demand?.enterpriseId,
          relation: item.relation.value,
          projectName: item.project?.projectName,
          gmtCreated: item.demand?.gmtCreated,
          contact: item.project?.contact,
          docFilesUrl: item.project?.docFilesUrl,
          isCreated,
          projectId: item.project?.id,
          remarks: item.project?.remarks,
          enterpriseName:item.enterpriseUserEntity?.enterpriseName
        });
      });
    },
    async getAllCooperativeUser() {
      let resultData = await ReqCooperativeUser();
      let {
        page: { list },
      } = resultData;
      this.cooperativeUser = list;
      console.log(";", this.cooperativeUser);
    },
    async getAllEnterPriseUser() {
      let resultData = await ReqEnterPriseUser();
      const {
        page: { list },
      } = resultData;
      this.enterPriseUser = list;
    },
    async createProjectBtn() {
      this.newArr.forEach((item) => {
        this.ruleForm.userRelations.push({
          cooperativeId: item[0],
          personalId: item[1],
          position: this.placeData,
        });
      });
      const resultData = await ReqAddProject(this.ruleForm);
      const { msg } = resultData;
      if (msg === "success") {
        this.$message({
          type: "success",
          message: "项目创建成功",
        });
        this.ruleForm = {
          demandId: "",
          projectName: "",
          contact: "",
          categoryId: "",
          userRelations: [],
          createdAdminId: 1,
          docFilesUrl: "",
        };
        this.createSubjectVisible = false;
        await this.getAllDemend();
      }
    },
    // 获取全部的合作伙伴用户以及全部的个人顾问
    // async getCooperPersonUser() {
    //   let arr = [];
    //   let resultData = await ReqCooperPersonUser();
    //   const { pg } = resultData;
    //   pg.forEach((first) => {
    //     let obj = {};
    //     obj.value = first.id;
    //     obj.label = first.industry;
    //     obj.children = [];
    //     first.personalUserEntities.forEach((second) => {
    //       const index = obj.children.findIndex(
    //         (item) => item.value == second?.userInfo.expertise
    //       );
    //       if (index !== -1) {
    //         obj.children[index].children.push({
    //           value: second.userInfo.id,
    //           label: second.userInfo.name,
    //         });
    //       } else {
    //         obj.children.push({
    //           value: second.userInfo.expertise,
    //           label: second.userInfo.expertise,
    //           children: [
    //             {
    //               value: second.userInfo.id,
    //               label: second.userInfo.name,
    //             },
    //           ],
    //         });
    //       }
    //     });
    //     arr.push(obj);
    //   });
    //   this.options = arr;
    // },
    // 获取项目角色
    async getProjectRole() {
      let roleArr = []; //角色数组
      let resultData = await ReqCooperPersonUser();
      const { pg } = resultData;
      pg.forEach((item) => {
        item.personalUserEntities.forEach((it) => {
          const {
            userInfo: { expertise, name, id },
          } = it;
          this.otherCpnusers.push({ name, id });
          roleArr.push(expertise);
        });
      });
      roleArr = [...new Set(roleArr)]; //去重操作
      this.roles = roleArr;
      console.log(this.otherCpnusers);
    },
    //查询本公司的全部个人顾问用户
    // async getAllMyCpnUser() {
    //   let res = await ReqPersonalUser({ limit: 1000, page: 1 });
    //   const {
    //     page: { list },
    //   } = res;
    //   list.forEach((item) => {
    //     if (item) {
    //       const {
    //         userInfo: { name, id },
    //       } = item;
    //       this.myCpnusers.push({ name, id });
    //     }
    //   });
    //   console.log(this.myCpnusers);
    // },
    // // 查询全部的管理员用户
    // async getAllAdminUsers() {
    //   let res = await ReqadminList({ limit: 1000, page: 1 });
    //   const {
    //     page: { list },
    //   } = res;
    //   list.forEach((item) => {
    //     const { id, username } = item;
    //     this.adminUsers.push({ id, username });
    //   });
    //   console.log(this.adminUsers);
    // },
    // 删除人
    deleteOnePersonByInd(index) {
      this.currentPersonChoose.splice(index, 1);
    },
    // 三级联动
    handleChange(value) {
      console.log(value,"三级联动效果");
      this.newArr.push(value);
      let newArr = [];
      newArr.push(this.placeData);
      this.options.forEach((item) => {
        if (item.value == value[0]) {
          newArr.push(item.label);
          item.children.forEach((it) => {
            if (it.value == value[1]) {
              newArr.push(it.label);
            }
          });
        }
      });
      this.currentPersonChoose.push(newArr);
      value = [];
    },
    // 对项目进行评分
    async saveScoreProject() {
      if (this.isAccess) {
        const projectScore = {
          createdId: 1,
          scoreDetails: JSON.stringify(this.currentScore),
          scoredId: this.currentScore.project.projectId,
          socreSource: 1001,
          id: this.currentAccessId,
        };
        const resultData = await ReqUpdateScorePro(projectScore);
        const { code } = resultData;
        if (code === 0) {
          this.$message({
            type: "success",
            message: "修改成功",
          });
        }
      } else {
        const projectScore = {
          createdId: 1,
          scoreDetails: JSON.stringify(this.currentScore),
          scoredId: this.currentScore.project.projectId,
          socreSource: 1001,
        };
        const resultData = await ReqProjectScore(projectScore);
        const { code } = resultData;
        if (code === 0) {
          this.$message({
            type: "success",
            message: "评分成功",
          });
        }
      }
      this.subjectAssessVisible = false;
    },
    // 取消创建项目
    cancelCreateProject() {
      this.newArr = [];
      this.currentPersonChoose = [];
      this.createSubjectVisible = false;
    },
    // 整合三级联动数据
    async dealOptions() {
      let arr = [];
      let resultData = await ReqCooperPersonUser();
      let myCompany = await ReqPersonal({id:1})
      const { pg } = resultData;
      pg.push(myCompany.data)
      pg.forEach((first) => {
        let obj = {};
        obj.value = first.id;
        obj.label = first.industry;
        obj.children = [];
        first.personalUserEntities.forEach((second) => {
          obj.children.push({
            value: second.userInfo.id,
            label: second.userInfo.name,
          })
        });
        arr.push(obj);
      });
      this.options = arr;
    },
    // 每一页条数变化
    handleSizeChange(val) {
      this.pageSize = val;
      this.getAllDemend();
    },
    // 当前页发生变化
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getAllDemend();
    },
    // 改变状态
    changeStatus(value) {
      this.demandStatus = value;
      console.log(value);
    },
    timeChange(value) {
      this.timeDemand = new Date(value).getTime();
      this.timeDemand = dayjs(this.timeDemand).format("YYYY-MM-DD 00:00:00");
    },
    // 搜索状态和时间
    async searchDemand() {
      const requestData = {
        date: this.timeDemand,
        status: this.demandStatus,
        category: this.demandCategory,
        describes: this.demandDescribes,
        enter_name: this.demandEnter_name,
        name: this.demandName,
        pro_name: this.demandPro_name,
      };
      // console.log(requestData)
      if (!this.timeDemand) {
        delete requestData.date;
      }
      const resultData = await ReqDemandByStatus(requestData);
      // console.log(resultData);
      // 拿到结果解析
      const { demandVo } = resultData;
      this.allShowInfo = [];
      demandVo.forEach((item) => {
        let isCreated;
        if (item.project) {
          isCreated = true;
        } else {
          isCreated = false;
        }
        // console.log(item);
        this.allShowInfo.push({
          demandId: item.demand?.id,
          demandName: item.demand?.demandName,
          demandDescribe: item.demand?.demandDescribe,
          docReqFilesUrl: item.demand?.docFilesUrl,
          enterpriseId: item.demand?.enterpriseId,
          relation: item.relation.value,
          projectName: item.project?.projectName,
          gmtCreated: item.demand?.gmtCreated,
          contact: item.project?.contact,
          docFilesUrl: item.demand?.docFilesUrl,
          demandStatus: item.demand?.status,
          isCreated,
          projectId: item.project?.id,
          remarks: item.project?.remarks,
        });
      });
      //  console.log(this.allShowInfo)
    },
    // 取消搜索
    cancelSearchDemand() {
      this.timeDemand =''
      this.demandStatus=''
      this.getAllDemend()
    },
    // 查看项目
    enterProject(){
      this.$router.history.push(
          `/self/manage/projectAll`
        );
    },
  },
  async created() {
    this.userType = sessionStorage.getItem("userType");
    this.username = this.userType == 13 ? "超级管理用户" : "管理用户";
    await this.getAllDemend();
    await this.getAllEnterPriseUser();
    await this.getAllReqClassify();
    // await this.getCooperPersonUser();
    await this.getProjectRole();
    // await this.getAllMyCpnUser();
    // await this.getAllAdminUsers();
    await this.dealOptions(); //整合三级联动数据
  },
};
</script>

<style scoped>
@import url("~@/assets/styles/manage/reqAll.css");
</style>
